<include file="Inc/header" />
<div class="margin10px">
    <table class="mytable">
        <tr>
            <th width="40">ID</th>
            <th width="60">排序</th>
            <th>节点名称</th>
            <th>节点地址</th>
            <th width="100">显示级别</th>
            <th width="60">状态</th>
            <th width="230">操作</th>
        </tr>
        <?php if($list){foreach($list as $v){?>
        <tr <?php if($v['node_pid']==0){echo 'class="bglightyellow"';}?> >
            <td class="tdf"><?php echo $v['node_id'];;?></td>
            <td><?php echo $v['px'];?></td>
            <td><strong><?php echo $v['node_name'];?></strong></td>
            <td><strong><?php echo $v['m_c_a'];?></strong></td>
            <td <?php if($v['node_level']==1 || $v['node_level']==2){echo 'class="bglightgreen"';}?> ><?php if($v['node_level']==1){echo '顶部菜单';}elseif($v['node_level']==2){echo '左边一级菜单';}elseif($v['node_level']==3){echo '左边二级子单';}elseif($v['node_level']>3){echo '隐藏式菜单';}?></td>
            <td align="center"><span class="cursorpointer" onclick="nodeStatus(<?php echo $v['node_id'];?>, <?php echo (1-$v['st']);?>)"><?php if($v['st']==1){echo '<font color="green">正常</font>';}else{echo '<font color="red">禁用</font>';}?></span></td>
            <td>
                <a href="<?php echo U('admin/acl/node_add', array('node_pid'=>$v['node_id']));?>">添加子菜单</a> /
                <?php if($v['node_pid'] == 0){?><a href="<?php echo U('admin/acl/node_list', array('node_pid'=>$v['node_id']));?>">管理子菜单</a> / <?php }?>
                <a href="<?php echo U('admin/acl/node_del', array('node_id'=>$v['node_id']));?>" onclick="javascript:return confirm('提示：您确定要删除吗？')">删除</a> /
                <a href="<?php echo U('admin/acl/node_edit', array('node_id'=>$v['node_id']));?>">修改</a>
            </td>
        </tr>

        <!--Begin::左边二级菜单、隐藏菜单-->
        <?php if(is_array($v['_sub'])){foreach($v['_sub'] as $vv){?>
            <tr>
                <td class="tdf"><?php echo $vv['node_id'];;?></td>
                <td style="padding-left:30px;"><?php echo $vv['px'];?></td>
                <td style="padding-left:30px;"><?php echo $vv['node_name'];?></td>
                <td style="padding-left:30px;"><?php echo $vv['m_c_a'];?></td>
                <td <?php if($vv['node_level']==1){echo 'class="bglightgreen"';}?> ><?php if($vv['node_level']==1){echo '顶部菜单';}elseif($vv['node_level']==2){echo '左边一级菜单';}elseif($vv['node_level']==3){echo '左边二级子单';}elseif($vv['node_level']>3){echo '隐藏式菜单';}?></td>
                <td align="center"><span class="cursorpointer" onclick="nodeStatus(<?php echo $vv['node_id'];?>, <?php echo (1-$vv['st']);?>)"><?php if($vv['st']==1){echo '<font color="green">正常</font>';}else{echo '<font color="red">禁用</font>';}?></span></td>
                <td>
                    <a href="<?php echo U('admin/acl/node_del', array('node_id'=>$vv['node_id']));?>" onclick="javascript:return confirm('提示：您确定要删除吗？')">删除</a> /
                    <a href="<?php echo U('admin/acl/node_edit', array('node_id'=>$vv['node_id']));?>">修改</a>
                </td>
            </tr>
            <?php }}?>
        <!--End::左边二级菜单、隐藏菜单-->

        <?php }}else{?>
        <tr>
            <td colspan="8">没有数据</td>
        </tr>
        <?php }?>
    </table>
</div>
<script type="text/javascript">
    function nodeStatus(node_id, st){
        $.ajax({
            url:'<?php echo U('admin/acl/ajax_node_st');?>',
            data:({'node_id':node_id, 'st':st}),
            type:'post',
            success:function(msg){
                if(msg == 'ok'){
                    alert('操作成功');
                    location.reload();
                }else{
                    alert(msg);
                }
            },
            error:function(){
                alert('网络繁忙，请稍后重试');
            }
        })
    }
</script>
<include file="Inc/footer" />